package view.code
{
	import com.adobe.cairngorm.control.CairngormEventDispatcher;

	import flash.events.MouseEvent;

	import mvc.control.CharacterEvent;

	import mx.containers.HBox;
	import mx.containers.VBox;

	import orm.fantasy.TblCharacterVO;

	import view.design.DesignSlot;

	public class CodeCharacter extends HBox
	{
		private var _tblCharacterVO:TblCharacterVO;

		public var vboxSlots:VBox;

		public function CodeCharacter()
		{
			super();

		}

		public function set tblCharacterVO(data:TblCharacterVO):void
		{
			_tblCharacterVO = data;

			this.label = _tblCharacterVO.char_name;
		}

		public function get tblCharacterVO():TblCharacterVO
		{
			return _tblCharacterVO;
		}
		private var _designSlots:Array

		public function get designSlots():Array
		{
			if(_designSlots == null)
			{
				_designSlots = [];
				for each(var hbox:HBox in this.vboxSlots.getChildren())
				{
					for each(var slot:DesignSlot in hbox.getChildren())
					{
						_designSlots.push(slot);
					}
				}
			}
			return _designSlots;
		}

		protected function btnSuicide_clickHandler(event:MouseEvent):void
		{
			var mvcEvent:CharacterEvent = new CharacterEvent(CharacterEvent.REMOVE_CHARACTER, _tblCharacterVO);
			mvcEvent.data = {dsnCharacter: this};
			CairngormEventDispatcher.getInstance().dispatchEvent(mvcEvent);
		}
	}
}